package com.condroid;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * This class is used for console like interface for scrolling.
 * Refer to "Write a Console App on Android using Java" by Chilap 
 * {@link http://www.codeproject.com/KB/android/cmdconsole.aspx}
 */
public class ConsoleView extends ScrollView {
	private ScrollViewListener scrollViewListener = null;

	public ConsoleView(Context context) {
        super(context);
    }
	
	public ConsoleView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
	
	public ConsoleView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}
	
	public void setScrollViewListener(ScrollViewListener scrollViewListener) {
        this.scrollViewListener = scrollViewListener;
    }
 
    @Override
    protected void onScrollChanged(int l, int t, int oldl, int oldt){
    	super.onScrollChanged(l, t, oldl, oldt);
 	    if (scrollViewListener != null)
 	    	scrollViewListener.onViewScroll(l, t, oldl, oldt);
    }
	
	public interface ScrollViewListener{
    	void onViewScroll(int x, int y, int oldx, int oldy);
    }
}
